package com.groupnections.client.Entities;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.groupnections.client.utilities.FormField;
import com.groupnections.shared.Entity;

public class ConnectEntityForm extends VerticalPanel {

	public static TextBox connect = new TextBox();

	public ConnectEntityForm(Entity entity) {

		this.add(FormField.getFormField("Add a connection", connect));

		this.add(saveEntity(entity));
	}

	public Button saveEntity(final Entity entity) {

		Button save = new Button("Connect");

		save.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {

				new ConnectEntity(entity, connect.getValue());
			}
		});

		return save;
	}
}
